Learn R Programming

Rfast (version 1.2)

Column-wise minimum and maximum (in parallel): Column-wise minimum and maximum of a matrix

Description

Column-wise minimum and maximum of a matrix in parallel.

Usage

colMins(x, value=FALSE)
colMaxs(x, value=FALSE)
colMins_parallel(x, ncores, value = FALSE)
colMaxs_parallel(x, ncores, value = FALSE)

Arguments

x
A numerical matrix with data.
ncores
The number of cores to use.
value
If the value is TRUE it returns the indices of the minimum/maximum, otherwise it returns the minimum and maximum values.

Value

A vector with the relevant values.

See Also

rowMins, rowMaxs, nth, colMedians, colVars, sort_mat

Examples

Run this code
x <- matrix( rnorm(1000 * 2000), ncol = 2000 )

system.time( colMins(x) )
system.time( apply(x, 2, min) )
s1 = colMins(x)
s2 = apply(x, 2, min)

system.time( colMaxs(x) )
system.time( apply(x, 2, max) )
s1 = colMaxs(x)
s2 = apply(x, 2, max)

system.time( colMins_parallel(x, ncores = 2) )
system.time( apply(x, 2, min) )
s1 = colMins_parallel(x, ncores = 2)
s2 = apply(x, 2, min)

Run the code above in your browser using DataLab